package com.ruoyi.web.controller.combat.userlocation;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.combat.domain.userlocation.ConfuseUser;
import com.ruoyi.combat.service.userlocation.IConfuseUserService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 混淆社群Controller
 * 
 * @author ruoyi
 * @date 2025-04-02
 */
@RestController
@RequestMapping("/combat/confuseUser")
public class ConfuseUserController extends BaseController
{
    @Autowired
    private IConfuseUserService confuseUserService;

    /**
     * 查询混淆社群列表
     */
    @PreAuthorize("@ss.hasPermi('combat:confuseUser:list')")
    @GetMapping("/list")
    public TableDataInfo list(ConfuseUser confuseUser)
    {
        startPage();
        List<ConfuseUser> list = confuseUserService.selectConfuseUserList(confuseUser);
        return getDataTable(list);
    }

    /**
     * 导出混淆社群列表
     */
    @PreAuthorize("@ss.hasPermi('combat:confuseUser:export')")
    @Log(title = "混淆社群", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ConfuseUser confuseUser)
    {
        List<ConfuseUser> list = confuseUserService.selectConfuseUserList(confuseUser);
        ExcelUtil<ConfuseUser> util = new ExcelUtil<ConfuseUser>(ConfuseUser.class);
        util.exportExcel(response, list, "混淆社群数据");
    }

    /**
     * 获取混淆社群详细信息
     */
    @PreAuthorize("@ss.hasPermi('combat:confuseUser:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(confuseUserService.selectConfuseUserById(id));
    }

    /**
     * 新增混淆社群
     */
    @PreAuthorize("@ss.hasPermi('combat:confuseUser:add')")
    @Log(title = "混淆社群", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ConfuseUser confuseUser)
    {
        return toAjax(confuseUserService.insertConfuseUser(confuseUser));
    }

    /**
     * 修改混淆社群
     */
    @PreAuthorize("@ss.hasPermi('combat:confuseUser:edit')")
    @Log(title = "混淆社群", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ConfuseUser confuseUser)
    {
        return toAjax(confuseUserService.updateConfuseUser(confuseUser));
    }

    /**
     * 删除混淆社群
     */
    @PreAuthorize("@ss.hasPermi('combat:confuseUser:remove')")
    @Log(title = "混淆社群", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(confuseUserService.deleteConfuseUserByIds(ids));
    }
}
